package com.elite.groovy.callback;

import groovy.json.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import com.elite.groovy.util.EliteBean;
import java.security.MessageDigest;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;

import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.wisdge.dataservice.Result;
import com.elite.groovy.util.Util;
import cn.com.kh.HttpClientProxy;
import javax.servlet.http.HttpSession;
import com.tplife.dm.model.dmfsuser.DmFsUserVO;

public class SetSession implements ServiceBackInvoke{
	private static final Log log=LogFactory.getLog(SetSession.class);
	public String doCallBack(EliteBean eliteBean,HttpServletRequest request,HttpServletResponse response) {

		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		log.debug("apiInterfaceTest start-----------------");
		//使用request对象的getSession()获取session，如果session不存在则创建一个
		HttpSession session = request.getSession();
		//获取session的Id
		String sessionId = session.getId();
		log.debug("sessionid:"+sessionId);
		String loginName = request.getParameter("loginName");
		log.debug("Call SetSessionServlet ----- loginname is " + loginName);
		DmFsUserVO userVO = new DmFsUserVO();
		userVO.setUserName(loginName);
		session.setAttribute("dm_fs_user", userVO);
		log.info("dm_fs_user : " + ((DmFsUserVO)session.getAttribute("dm_fs_user")).getUserName() + " in session " + session.getId());		
		return session.getId();
	}
}